package com.alix.paymoney.base;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;

import com.alix.paymoney.R;
import com.alix.paymoney.entity.Channel;
import com.alix.paymoney.ui.WebActivity;
import com.alix.paymoney.utils.ImageUtils;

import java.util.List;

/**
 * Created by wushiqian on 2017/11/16.
 */

public class ChannelAdapter extends BaseAdapter<Channel> {
    public ChannelAdapter(Context context, List<Channel> list) {
        super(context, list);
    }

    @Override
    public View getLayoutView(ViewGroup parent, int viewType) {
        return getView(parent, R.layout.recycler_view_item_channel);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        final Channel channel = list.get(position);
        ImageUtils.load(context,channel.getImgUrl(),holder.getImageView(R.id.logo));
        holder.getTextView(R.id.name).setText(channel.getName());
        holder.getTextView(R.id.max_money).setText(channel.getMaxAmount());
        holder.getTextView(R.id.pass_rate).setText(channel.getPassRate());
        holder.getTextView(R.id.time).setText(channel.getPayTime());
        holder.getTextView(R.id.content).setText(channel.getContent());
        holder.getTextView(R.id.apply).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WebActivity.go(context,channel.getUrl(),"");
            }
        });
    }
}
